rm(list = ls())
WorldLink="https://github.com/lcampos2111/Tarea-1/raw/refs/heads/main/World_8857.gpkg/"
library(sf)
## Linking to GEOS 3.13.1, GDAL 3.11.0, PROJ 9.6.0; sf_use_s2() is TRUE
st_layers(WorldLink)
## Warning in CPL_get_layers(dsn, options, do_count): GDAL Message 1: File
## /vsimem/.#!HIDDEN!#./1/_gdal_http_ has GPKG application_id, but non conformant
## file extension
World <- st_read(WorldLink, layer = "continent")
## Warning in CPL_read_ogr(dsn, layer, query, as.character(options), quiet, : GDAL
## Message 1: File /vsimem/.#!HIDDEN!#./2/_gdal_http_ has GPKG application_id, but
## non conformant file extension
## Reading layer `continent' from data source
## `https://github.com/lcampos2111/Tarea-1/raw/refs/heads/main/World_8857.gpkg/'
## using driver `GPKG'
## Simple feature collection with 225 features and 6 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -16921600 ymin: -8392928 xmax: 17080820 ymax: 8315707
## Projected CRS: WGS 84 / Equal Earth Greenwich
WorldMob_ddm <- st_read(WorldLink, layer = "value_ddm")
## Warning in CPL_read_ogr(dsn, layer, query, as.character(options), quiet, : GDAL
## Message 1: File /vsimem/.#!HIDDEN!#./3/_gdal_http_ has GPKG application_id, but
## non conformant file extension
## Reading layer `value_ddm' from data source
## `https://github.com/lcampos2111/Tarea-1/raw/refs/heads/main/World_8857.gpkg/'
## using driver `GPKG'
## Simple feature collection with 87943 features and 0 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -16921580 ymin: -6791555 xmax: 16800860 ymax: 8298783
## Projected CRS: WGS 84 / Equal Earth Greenwich
WorldMob_psm <- st_read(WorldLink, layer = "value_psm")
## Warning in CPL_read_ogr(dsn, layer, query, as.character(options), quiet, : GDAL
## Message 1: File /vsimem/.#!HIDDEN!#./4/_gdal_http_ has GPKG application_id, but
## non conformant file extension
## Reading layer `value_psm' from data source
## `https://github.com/lcampos2111/Tarea-1/raw/refs/heads/main/World_8857.gpkg/'
## using driver `GPKG'
## Simple feature collection with 225 features and 8 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -16921040 ymin: -7791845 xmax: 17079590 ymax: 8198921
## Projected CRS: WGS 84 / Equal Earth Greenwich
st_crs(World)$epsg
## [1] 8857
library(ggplot2)
library(scales)
ggplot() +
#call map
geom_sf(data = World) +
# adjust datum
coord_sf(datum = st_crs(World)) +
# custom X and Y axes
scale_x_continuous(labels = label_number(scale = 1/1000, suffix = " km")) +
scale_y_continuous(labels = label_number(scale = 1/1000, suffix = " km")) +
labs(x = "Easting", y = "Northing") #labels
# DDM - static
ggplot() + theme_light() +
#base
geom_sf(data = World,fill="white",color="grey80") +
# layer
geom_sf(data=WorldMob_ddm,
alpha=0.1,#transparancy
shape=20,
size=1,
color="red")+
coord_sf(datum = st_crs(World)) # at the end of maps
# DDM - interactive
library(leaflet)
# needs geographic CRS
ddm_4326 <- st_transform(WorldMob_ddm, crs = 4326)
leaflet() %>%
addTiles() %>% # base map
addCircleMarkers(data = ddm_4326,
color="red",
radius = 0.01,
opacity = 0.1)
Almost the same:
leaflet() %>%
addProviderTiles(providers$CartoDB.Positron) %>% # names in english
addCircleMarkers(data = ddm_4326,
color="red",
radius = 0.01,
opacity = 0.1)
ggplot() + theme_light() +
#base
geom_sf(data = World,fill="white",color="grey80") +
# layer
geom_sf(data=WorldMob_psm,
shape=20,
color="red",aes(size=size))+
coord_sf(datum = st_crs(World)) # at the end of maps
# PSM - interactive
# CRS for leaflet
psm_4326 <- st_transform(WorldMob_psm, crs = 4326)
leaflet() %>%
addProviderTiles(providers$CartoDB.Positron) %>%
addCircleMarkers(data = psm_4326,
# fillColor = "red",
# stroke = T, #border
# color="red", #border color
# fillOpacity = 1,
label = ~Country,
radius = ~size/10)